<template>
    <div class="ele-body">
        <el-card shadow="never">
            <el-tabs v-model="activeName" @tab-click="handleClick">
                <el-tab-pane label="短信配置" name="shortMessage"></el-tab-pane>
            </el-tabs>
            <el-form
                :model="where"
                label-width="77px"
            >
                <el-form-item label="短信配置:">
                    <el-radio-group v-model="where.value">
                        <el-radio label="SmsChuangLan">创蓝</el-radio>
                        <el-radio label="SmsSubmail">SUBMAIL</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="save" :loading="loading"
                        >保存
                    </el-button>
                </el-form-item>
            </el-form> 
        </el-card>
    </div>
</template>
<script>
export default {
    data() {
        return{
            activeName: 'shortMessage',
            loading:false,
            where:{
                value:'',
            }
        }
    },
    mounted(){
        this.queryWhere()
    },
    methods: {
         //獲取默認配置
         queryWhere(){
            this.$http.post('/Defaultconfig/getDefaultConfig',{name:'sms_type'}).then(res=>{
                if(res.data.code === 0){
                    this.where.value=res.data.data.value
                }else{
                    this.$message.error(res.data.msg);
                }
            })
        },
        //保存默認配置
        save(){
            this.$http.post('/Defaultconfig/setDefaultConfig',{name:'sms_type',value:this.where.value}).then(res=>{
                if(res.data.code === 0){
                    this.$message.success('保存成功!');
                    this.queryWhere()
                }else{
                    this.$message.error(res.data.msg);
                }
            })
        },
        handleClick(tab, event) {
            console.log(tab, event);
        },
    },
}
</script>
<style scoped></style>